package util;

public class Node implements Comparable<Node>{
	
	public enum NodeState {
		CLOSEDLIST,
		OPENLIST,
		UNKNOWN
		
	}
	
	public enum LastNode{
		NORTH, EAST, SOUTH, WEST,
		NORTHEAST, SOUTHEAST, SOUTHWEST, NORTHWEST
	}
	
	private boolean obstacle = false;
	private boolean isStart = false;
	private boolean isTarget = false;
	
	private int size;
	private int x;
	private int y;
	
	private int gCosts;
	private int hCosts;
	private int costs;
	
	private LastNode last;
	
	private NodeState state;
	
	public Node (int x, int y) {
		size = PublicVars.getNodeSize();
		this.x = x;
		this.y = y;
		state = NodeState.UNKNOWN;
		
	}
	
	public Node (int x, int y, int gCost){
		this(x,y);
		gCosts = gCost;
	}
	
	public NodeState getState() {
		return state;
	}

	public int getSize() {
		return size;
	}

	public void setSize(int size) {
		this.size = size;
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public int getgCosts() {
		return gCosts;
	}

	public void setgCosts(int d) {
		this.gCosts = d;
	}

	public int gethCosts() {
		return hCosts;
	}

	public void sethCosts(int hCosts) {
		this.hCosts = hCosts;
	}

	public int getCosts() {
		costs = gCosts + hCosts;
		return costs;
	}

	public void setCosts(int costs) {
		this.costs = costs;
	}

	public void setState(NodeState state) {
		this.state = state;
	}

	public boolean isObstacle() {
		return obstacle;
	}

	public void setObstacle(boolean obstacle) {
		this.obstacle = obstacle;
	}

	@Override
	public int compareTo(Node o) {
		if(this.getCosts() < o.getCosts()){
			return -1;
		} else if(this.getCosts() > o.getCosts()){
			return 1;
		} else{
			return 0;
		}
		
	}

	public boolean isStart() {
		return isStart;
	}

	public void setStart(boolean isStart) {
		this.isStart = isStart;
	}

	public boolean isTarget() {
		return isTarget;
	}

	public void setTarget(boolean isTarget) {
		this.isTarget = isTarget;
	}

	public LastNode getLast() {
		return last;
	}

	public void setLast(LastNode last) {
		this.last = last;
	}

	@Override
	public String toString() {
		return "Node [costs=" + costs + "]";
	}
}

